<?php

	include_once("include/config.php");
	include_once("include/auth.lib.php");
	include_once("include/functions.php");

	require 'include/excel.php';
	
	$sql = "SELECT a.id, id_palestra, p.nome nome_palestra, cognomenome, categoria, peso, c.desc  
			  FROM atleti a 
			  JOIN palestre p ON (a.id_palestra = p.id) 
			  LEFT JOIN categorie c ON (a.categoria = c.id)
			 ORDER BY cognomenome";
	$result = runSQL($sql);
	
	$data = array();
	$data = array(1 => array ('Cognome e nome atleta', 'Palestra', 'Categoria', 'Peso'));
	while ($row = mysql_fetch_assoc($result)) {
		$data[] = array($row['cognomenome'], $row['nome_palestra'], $row['desc'], $row['peso']);
	}

	// create a simple 2-dimensional array
	/*$data = array(
			1 => array ('Nome', 'Istruttore'),
			array('Test1', 'Istr1'),
			array('Test2', 'Istr2')
			);*/

	// generate file (constructor parameters are optional)
	$xls = new Excel_XML('UTF-8', false, 'Workflow Management');
	$xls->addArray($data);
	$xls->generateXML('Atleti');

?>